Equipment Collections

Equipment may be grouped into collections based on a key value. The key is defined by the user and must a numeric user property. The initial value of the property is used to identify the equipment within the collection.

The collection may be searched at a later time, the equipment that has the requested key value is returned to the caller.

 

void SetComponentKey(userPropName: string);

Called to setup a collection, keyed by the user property 'userPropName'

 

Name Type Description
userPropName String The name of the user property that is to be the key value

object GetComponentByKey(userPropName: string, keyValue: number);

Called to get the equipment associated with the key value

 

Name Type Description
userPropName String The name of the user property that is to be the key value
keyValue Number The value of the key

The return value is the equipment with the associated key value, this call will return 'null' if the key value cannot be found

Example:

function OnSimulationStart() {
  SetComponentKey("LocationID");
}

function ProductTracking(msg, hdr) {
  var product = UpdateProductPosition(GetComponentByKey("LocationID", msg.locationid), msg.distance, msg.BC);
  if (product != null) {
    product.Text = msg.BC;
    product.Length = msg.l;
    product.Width = msg.w;
    product.Height = msg.h;
    product.Direction = msg.d;
  }
}

 

GetComponentKey and SetComponentKey only works with transport equipment, not with products. To find product try GetProductFromID(String Identifier); where Identifier is product.Identifier.